#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;
using db = double;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 110;

int n;

namespace trie {
	const int N = 1e4 + 10;
	int ch[N][2],ndn,val[N];
	void reset() { for(int i = 1;i <= ndn;i++) ch[i][0] = ch[i][1] = val[i] = 0; ndn = 1; }
	void insert(char *s) {
		int p = 1;
		for(int i = 1;i <= n;i++) {
			int x = s[i] - '0';
			if(!ch[p][x]) ch[p][x] = ++ndn;
			p = ch[p][x];
		} val[p] = true;
	}
	void dfs(int x) {
		if(!x) return;
		dfs(ch[x][0]); dfs(ch[x][1]);
		val[x] |= val[ch[x][0]] & val[ch[x][1]];
	}
	void calc() { dfs(1); }
	void output() {
		int p = 1;
		for(int i = 1;i <= n;i++) {
			if(!val[ch[p][0]]) p = ch[p][0],putchar('0');
			else p = ch[p][1],putchar('1');
		} puts("");
	}
}

char s[N];

void solve() {
	n = in; trie :: reset();
	for(int i = 1;i <= n;i++) scanf("%s",s + 1),trie :: insert(s);
	trie :: calc(); trie :: output(); 
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    for(int T = in;T;T--) solve(); return 0;
}
